using System;
using System.Globalization;
using System.Threading;

namespace ObjectThinking.Globalization
{
    public static class DescriptionFormatter
    {
        public static string MustBeOfType(string name, Type type)
        {
            return String.Format(
                Thread.CurrentThread.CurrentUICulture,
                Properties.Resources.DescriptionFormatterMustBeOfType,
                name, type
                );
        }

        public static string ObjectRequired(string name)
        {
            return String.Format(
                Thread.CurrentThread.CurrentUICulture,
                Properties.Resources.DescriptionFormatterObjectRequired,
                name
                );
        }

        public static string StringEmpty(string name)
        {
            return String.Format(
                Thread.CurrentThread.CurrentUICulture,
                Properties.Resources.DescriptionFormatterStringEmpty,
                name
                );
        }

        public static string StringMaxLength(string name, int maxLength)
        {
            string value = null;

            if (maxLength == 1)
            {
                value = String.Format(
                    Thread.CurrentThread.CurrentUICulture,
                    Properties.Resources.DescriptionFormatterStringMaxLengthSingular,
                    name
                    );
            }
            else
            {
                value = String.Format(
                    Thread.CurrentThread.CurrentUICulture,
                    Properties.Resources.DescriptionFormatterStringMaxLengthPlural,
                    name, maxLength
                    );
            }

            return value;
        }

        public static string StringMinLength(string name, int minLength)
        {
            string value = null;

            if (minLength == 1)
            {
                value = String.Format(
                    Thread.CurrentThread.CurrentUICulture,
                    Properties.Resources.DescriptionFormatterStringMinLengthSingular,
                    name
                    );
            }
            else
            {
                value = String.Format(
                    Thread.CurrentThread.CurrentUICulture,
                    Properties.Resources.DescriptionFormatterStringMinLengthPlural,
                    name, minLength
                    );
            }

            return value;
        }
    }
}